require('../../assets/css/index.less')
require('../../assets/fonts/iconfont.css')
require('../../lib/weui/weui.css');
require("./introduce.less")
let weui = require('../../lib/weui/weui.js');

const dom = require('../../utils/dom');
const https = require('../../utils/https');
const local = require('../../utils/local');
dom.ready(function() {
    console.log(local.get("fragments"));
    let a = local.get("fragments");
    let video = dom.gete("video")
    video.src = "http://fitness.h5.itsource.cn:3701" + a[0].videoUrl;

    let flag = true;
    dom.addevent(".play", function() {
        if (flag) {
            video.play();
            this.className = "iconfont icon-stop play"
        } else {
            video.pause();
            this.className = "iconfont icon-play play"
        }
        flag = !flag;
    })
    let index = 0;
    dom.addevent(".prepart", function() {
        if (index == a.length - 1) {
            index = 0
            video.src = "http://fitness.h5.itsource.cn:3701" + a[index].videoUrl;
        } else {
            index++;
            video.src = "http://fitness.h5.itsource.cn:3701" + a[index].videoUrl;
        }
    })



    dom.addevent(".nextpart", function() {
        if (index == 0) {
            index = a.length - 1;
            video.src = "http://fitness.h5.itsource.cn:3701" + a[index].videoUrl;
        } else {
            index--;
            video.src = "http://fitness.h5.itsource.cn:3701" + a[index].videoUrl;
        }
    })
})